/**
 * Copyright (c) 2015 Baidu. All Rights Reserved.
 *
 * @file dataParse模块单测
 * @author yuanguozheng
 */
var dataParser = require('../utils/dataParser');

exports.testDoParse = function (test) {
    var expectOcResult = [
        {
            "cls": "BDMNewsListDetailDataModel",
            "member": [
                {
                    "name": "id",
                    "type": "int",
                    "rawName": "ID",
                    "camelName": "id"
                },
                {
                    "name": "title",
                    "type": "NSString *",
                    "rawName": "Title",
                    "camelName": "title"
                },
                {
                    "name": "date",
                    "type": "NSString *",
                    "rawName": "Date",
                    "camelName": "date"
                }
            ]
        },
        {
            "cls": "BDMNewsListDetailModel",
            "member": [
                {
                    "name": "type",
                    "type": "NSString *",
                    "rawName": "Type",
                    "camelName": "type"
                },
                {
                    "name": "currentPage",
                    "type": "int",
                    "rawName": "CurrentPage",
                    "camelName": "currentPage"
                },
                {
                    "name": "pages",
                    "type": "int",
                    "rawName": "Pages",
                    "camelName": "pages"
                },
                {
                    "name": "amount",
                    "type": "int",
                    "rawName": "Amount",
                    "camelName": "amount"
                },
                {
                    "name": "data",
                    "type": "NSMutableArray *",
                    "rawName": "Data",
                    "camelName": "data"
                }
            ]
        },
        {
            "cls": "BDMNewsListModel",
            "member": [
                {
                    "name": "result",
                    "type": "BOOL",
                    "rawName": "Result",
                    "camelName": "result"
                },
                {
                    "name": "detail",
                    "type": "BDMNewsListDetailModel *",
                    "rawName": "Detail",
                    "camelName": "detail"
                }
            ]
        }
    ];
    var expectJavaResult = [
        {
            "cls": "NewsListDetailDataModel",
            "member": [
                {
                    "name": "Id",
                    "type": "int",
                    "rawName": "ID",
                    "camelName": "id"
                },
                {
                    "name": "Title",
                    "type": "String",
                    "rawName": "Title",
                    "camelName": "title"
                },
                {
                    "name": "Date",
                    "type": "String",
                    "rawName": "Date",
                    "camelName": "date"
                }
            ]
        },
        {
            "cls": "NewsListDetailModel",
            "member": [
                {
                    "name": "Type",
                    "type": "String",
                    "rawName": "Type",
                    "camelName": "type"
                },
                {
                    "name": "CurrentPage",
                    "type": "int",
                    "rawName": "CurrentPage",
                    "camelName": "currentPage"
                },
                {
                    "name": "Pages",
                    "type": "int",
                    "rawName": "Pages",
                    "camelName": "pages"
                },
                {
                    "name": "Amount",
                    "type": "int",
                    "rawName": "Amount",
                    "camelName": "amount"
                },
                {
                    "name": "Data",
                    "type": "List<NewsListDetailDataModel>",
                    "rawName": "Data",
                    "camelName": "data"
                }
            ]
        },
        {
            "cls": "NewsListModel",
            "member": [
                {
                    "name": "Result",
                    "type": "boolean",
                    "rawName": "Result",
                    "camelName": "result"
                },
                {
                    "name": "Detail",
                    "type": "NewsListDetailModel",
                    "rawName": "Detail",
                    "camelName": "detail"
                }
            ]
        }
    ];
    var rawJson = '{"Result":true,"Detail":{"Type":"公告","CurrentPage":1,"Pages":9,"Amount":161,' +
        '"Data":[{"ID":194,"Title":"2015年中秋节及国庆节放假期间开馆时间安排","Date":"2015-09-22"}]}}';
    var jsonObj = JSON.parse(rawJson);
    test.deepEqual(expectJavaResult, dataParser(jsonObj, 'java', 'NewsList'));
    test.deepEqual(expectOcResult, dataParser(jsonObj, 'oc', 'NewsList'));
    test.equal(null, dataParser(null, '', ''));
    test.done();
};